package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.dao.GeneDAO;
import lab.gene.dao.GeneWPCRFinalsDAO;
import lab.gene.pojo.Gene;
import lab.gene.pojo.GeneWPCRFinals;
import lab.gene.service.GeneWPCRFinalsService;
import lab.user.dao.UserDAO;
import lab.user.pojo.User;

public class GeneWPCRFinalsServiceImpl implements GeneWPCRFinalsService {

	@Override
	public GeneWPCRFinals getGeneWPCRFinalsByName(String geneName) {
		// TODO Auto-generated method stub
		
		GeneWPCRFinals ts = null;
		GeneWPCRFinalsDAO dao = new GeneWPCRFinalsDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		ts = dao.getGeneWPCRFinalsByName(g);
		return ts;
	}

	@Override
	public void addGeneWPCRFinals(String geneName, Date recordDate, String pno1, String pno2, int exsize, String strain, String comments, String userName) {
		// TODO Auto-generated method stub
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		GeneWPCRFinalsDAO dao = new GeneWPCRFinalsDAO();
		GeneWPCRFinals gr = new GeneWPCRFinals();
		gr.setComments(comments);
		gr.setDateModified(new Date());
		gr.setExsize(exsize);
		gr.setGene(g);
		gr.setPno1(pno1);
		gr.setPno2(pno2);
		gr.setRecordDate(recordDate);
		gr.setStrain(strain);
		gr.setUser(u);
		dao.addGeneWPCRFinals(gr);

	}

	@Override
	public List<GeneWPCRFinals> getGeneWPCRFinalsHistory(String geneName) {
		List<GeneWPCRFinals> g = null;
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		GeneWPCRFinalsDAO dao = new GeneWPCRFinalsDAO();
		g = dao.getGeneWPCRFinalsHistory(gene);
		return g;
	}

}
